// 市场销售 / 咨询登记管理

import r from '@/utils/request'
import { type ListResponseType, type ResponseType } from '../types'

enum API {
    questionGet = 'question/get',// 获取单条咨询登记信息
    questionList = "/question/list", // 咨询登记列表
    questionAdd = "/question/add", // 咨询登记添加
    questionUpdate = "/question/update", // 咨询登记修改
    questionDelete = "/question/delete", // 咨询登记删除
    questionDeleteAll = "/question/deleteAll", // 咨询登记批量删除
}

export interface questionGetResAPI {
    id:             number;
    companyId:      number;
    customerId:     number;
    type:           string;
    source:         string;
    name:           string;
    mobile:         string;
    relation:       string;
    visitTime:      string;
    content:        string;
    addTime:        string;
    state:          number;
    addAccountId:   number;
    customerName:   string;
    addAccountName: string;
    stateName:      string;
}

export function questionGetAPI(id:number):Promise<ResponseType<questionGetResAPI>> {
    return r.get( API.questionGet + '/' + id )
}

export interface questionListParams {
    page: number
    pageSize: number
    name: string
    customerName:string
    mobile: number
    state:number
    customerId:number
}

export interface questionListResAPI {
    id:             number;
    companyId:      number;
    customerId:     number;
    type:           string;
    source:         string;
    name:           string;
    mobile:         string;
    relation:       string;
    visitTime:      string;
    content:        string;
    addTime:        string;
    state:          number;
    addAccountId:   number;
    customerName:   string;
    addAccountName: string;
    stateName:      string;
}

export function getquestionListAPI(Params:questionListParams):Promise<ListResponseType<questionListResAPI[]>> {
    return r.get(API.questionList,Params)
}

export interface questionAddResAPI {
    id:             number;
    companyId:      number;
    customerId:     number;
    type:           string;
    source:         string;
    name:           string;
    mobile:         string;
    relation:       string;
    visitTime:      string;
    content:        string;
    addTime:        string;
    state:          number;
    addAccountId:   number;
    customerName:   any;
    addAccountName: any;
    stateName:      any;
}

export function questionAddAPI(Params:questionUpdateAndAddParams):Promise<ResponseType<questionAddResAPI>> {
    return r.post(API.questionAdd,Params)
}

export interface questionUpdateAndAddParams {
    id:         number;
    customerId: number;
    customerName: string;
    type:       string;
    source:     string;
    name:       string;
    mobile:     string;
    relation:   string;
    visitTime:  string;
    content:    string;
}

export interface questionUpdateResAPI { 
    id:             number;
    companyId:      number;
    customerId:     number;
    type:           string;
    source:         string;
    name:           string;
    mobile:         string;
    relation:       string;
    visitTime:      string;
    content:        string;
    addTime:        string;
    state:          number;
    addAccountId:   number;
    customerName:   any;
    addAccountName: any;
    stateName:      any;
}

export function questionUpdateAPI(Params:questionUpdateAndAddParams):Promise<ResponseType<questionUpdateResAPI>> {
    return r.put(API.questionUpdate,Params)
}

export function questionDeleteAPI(id:number):Promise<ResponseType<null>> {
    return r.delete(API.questionDelete+'/'+id)
}

export function questionDeleteAllAPI(ids: number[]): Promise<ResponseType<string>> {
    return r.post(API.questionDeleteAll,ids)
}